package com.xiaobai.netease_news.activities;

import android.app.Activity;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.ViewGroup;
import android.widget.ProgressBar;

import com.xiaobai.netease_news.R;
import com.xiaobai.netease_news.adapters.MyPagerAdapter;
import com.xiaobai.netease_news.fragments.VideoDetailFragment;
import com.xiaobai.netease_news.views.PagerSlidingTabStrip;

import java.util.LinkedList;
import java.util.List;

public class VideoDetailActivity extends FragmentActivity {

    private ViewGroup mediaController;
    private final String[] VIDEO_DETAIL_TAB_TITLES = {"推荐","跟帖"};
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video_detail);


        ViewPager viewPager = (ViewPager) findViewById(R.id.video_detail_view_pager);
        List<Fragment> fragments = new LinkedList<Fragment>();

        Fragment recommendFragment = new VideoDetailFragment();
        Bundle bundle = new Bundle();
        //TODO 添加数据 传入Fragment
        recommendFragment.setArguments(bundle);
        fragments.add(recommendFragment);



        Fragment replyFragment = new VideoDetailFragment();
        bundle = new Bundle();
        //TODO 添加数据 传入Fragment
        recommendFragment.setArguments(bundle);
        fragments.add(replyFragment);


        MyPagerAdapter adapter = new MyPagerAdapter(getSupportFragmentManager(), fragments, VIDEO_DETAIL_TAB_TITLES);//此处有bug
        viewPager.setAdapter(adapter);

        PagerSlidingTabStrip tabStrip = (PagerSlidingTabStrip) findViewById(R.id.video_detail_tab);
        tabStrip.setViewPager(viewPager);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_video_detail, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
